close

public abstract void close()

Closes the current browser instance and releases all allocated resources.

The unload and beforeunload JavaScript events will not be fired in this case. This method is equivalent of close(CloseOptions.newBuilder().build()).

If the browser is already closed, then this method does nothing.

See also


public abstract void close(CloseOptions options)

Closes the current browser instance according to the given options.

If the currently loaded web page registers the onbeforeunload JavaScript event and the given options tell the browser to fire the beforeunload event, then this method will not close the browser immediately.

In this case, the com.teamdev.jxbrowser.browser.callback.BeforeUnloadCallback will be invoked, and if the callback instructs the browser to stay on the web page, the browser will not close.

The following example demonstrates how to close the browser as if a user manually clicked the close button of the tab or window.

browser.close(CloseOptions.newBuilder()
        .fireBeforeUnload()
        .build());

If the browser is already closed, this method does nothing.

Since

7.6